import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-04-23
 * Time: 14:40
 */
class pair<T> {
    private T first;
    private T second;

    public pair(T first, T second) {
        this.first = first;
        this.second = second;
    }

    public T getFirst() {
        return first;
    }

    public void setFirst(T first) {
        this.first = first;
    }

    public T getSecond() {
        return second;
    }

    public void setSecond(T second) {
        this.second = second;
    }

}
class ArrayAlg{
    //写一个静态方法用来求出字符串数组中的最大值与最小值
    public static pair<String> minMax(String[] a) {
         if(a.length==0||a==null) {
             return null;
         }
         String min =a[0];
         String max = a[0];
        for (int i = 0; i < a.length; i++) {
            if(min.compareTo(a[i])>0){
                min=a[i];
            }
            if(max.compareTo(a[i])<0) {
                max =a[i];
            }
        }
        return new pair<>(max,min);
    }
}

public class TestDemo {
    public static void main(String[] args) {

        String[] words = {"marry","had","a","little","lamb"};
        pair<String> mm = ArrayAlg.minMax(words);
        System.out.println("min="+mm.getFirst());
        System.out.println("max="+mm.getSecond());
    }
}
